package jvm;

import java.util.ArrayList;
import java.util.List;

/**
 * java  堆溢出
 *  -Xms20M -Xmx20M -XX:+HeapDumpOnOutOfMemoryError
 * @author  wangs
 */
public class HeapOOM {
    static  class OOMObject{


    }

    public static void main(String[] args) {
        List<OOMObject> list = new ArrayList<OOMObject>();
        int i=0;
        while (true){
            i++;
            System.out.println("i = " + i);
            list.add(new OOMObject());
        }
    }

}
